package com.lanbu.web.controller.system;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.lanbu.common.annotation.Log;
import com.lanbu.common.core.controller.BaseController;
import com.lanbu.common.core.domain.AjaxResult;
import com.lanbu.common.enums.BusinessType;
import com.lanbu.system.domain.ZntModuleScore;
import com.lanbu.system.service.IZntModuleScoreService;
import com.lanbu.common.utils.poi.ExcelUtil;
import com.lanbu.common.core.page.TableDataInfo;

/**
 * 模块得分Controller
 *
 * @author lanbu
 * @date 2025-04-24
 */
@Api(tags = "模块得分Controller")
@RestController
@RequestMapping("/module/score")
public class ZntModuleScoreController extends BaseController
{
    @Autowired
    private IZntModuleScoreService zntModuleScoreService;


    @ApiOperation("查询模块得分列表")
    @PreAuthorize("@ss.hasPermi('module:score:list')")
    @GetMapping("/list")
    public TableDataInfo list(ZntModuleScore zntModuleScore)
    {
        startPage();
        List<ZntModuleScore> list = zntModuleScoreService.selectZntModuleScoreList(zntModuleScore);
        return getDataTable(list);
    }


    @ApiOperation("导出模块得分列表")
    @PreAuthorize("@ss.hasPermi('module:score:export')")
    @Log(title = "模块得分", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ZntModuleScore zntModuleScore)
    {
        List<ZntModuleScore> list = zntModuleScoreService.selectZntModuleScoreList(zntModuleScore);
        ExcelUtil<ZntModuleScore> util = new ExcelUtil<ZntModuleScore>(ZntModuleScore.class);
        util.exportExcel(response, list, "模块得分数据");
    }


    @ApiOperation("获取模块得分详细信息")
    @PreAuthorize("@ss.hasPermi('module:score:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(zntModuleScoreService.selectZntModuleScoreById(id));
    }


    @ApiOperation("新增模块得分")
    @PreAuthorize("@ss.hasPermi('module:score:add')")
    @Log(title = "模块得分", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ZntModuleScore zntModuleScore)
    {
        return toAjax(zntModuleScoreService.insertZntModuleScore(zntModuleScore));
    }

    @ApiOperation("修改模块得分")
    @PreAuthorize("@ss.hasPermi('module:score:edit')")
    @Log(title = "模块得分", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ZntModuleScore zntModuleScore)
    {
        return toAjax(zntModuleScoreService.updateZntModuleScore(zntModuleScore));
    }


    @ApiOperation("删除模块得分")
    @PreAuthorize("@ss.hasPermi('module:score:remove')")
    @Log(title = "模块得分", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(zntModuleScoreService.deleteZntModuleScoreByIds(ids));
    }
}
